package cc.vv.baselibrary.view.columnchart.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import cc.vv.baselibrary.R
import cc.vv.baselibrary.util.BaseTimeUtil
import cc.vv.baselibrary.util.LKLogUtil
import cc.vv.baselibrary.view.columnchart.GraphView
import cc.vv.baselibrary.view.columnchart.bean.ShowPopwinDataObj
import cc.vv.lkbasecomponent.base.ui.adapter.LKBaseSingleAdapter
import cc.vv.lkbasecomponent.base.ui.adapter.viewholder.LKBaseViewHolder

/**
 * 数据记录列表展示控件适配器
 * @author sun.li
 * @date 2018/7/25.
 */
class SingleViewHorizontalViewAdapter : LKBaseSingleAdapter<ShowPopwinDataObj, LKBaseViewHolder> {


    constructor(layoutResId: Int, data: List<ShowPopwinDataObj>?) : super(layoutResId, data)

    override fun convert(helper: LKBaseViewHolder, item: ShowPopwinDataObj) {
        try {
            val gv_dgil_chart_view = helper.getView<GraphView>(R.id.gv_dgil_chart_view)
            val tv_dgil_date = helper.getView<TextView>(R.id.tv_dgil_date)
            val view_socre_line = helper.getView<View>(R.id.view_socre_line)
            if (null != tv_dgil_date) {
                val date = BaseTimeUtil.getStrTime(item.timeStr, BaseTimeUtil.DATE_FORMAT_13)
                tv_dgil_date.text = date
            }
            if (null != gv_dgil_chart_view) {
                val valueFloat = item.valueData.toFloat()
                gv_dgil_chart_view.setDate(valueFloat, false, 100f)
            }
            //竖线是否显示
            if (view_socre_line != null) {
                view_socre_line.visibility = if (item.isShowLine) View.VISIBLE else View.GONE
            }
        } catch (e: Exception) {
            LKLogUtil.e(e.toString())
        }
    }
}